home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_2 / kmenu < prev    next >
Text File  |  1995-03-31  |  5KB  |  209 lines

  1. Article 1203 of comp.sys.handhelds:
  2. Path: en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!zaphod.mps.ohio-state.edu!sdd.hp.com!decwrl!apple!snorkelwacker!ai-lab!rice-chex!bson
  3. From: bson@rice-chex.ai.mit.edu (Jan Brittenson)
  4. Newsgroups: comp.sys.handhelds
  5. Subject: Kermit menu for HP48
  6. Message-ID: <10477@life.ai.mit.edu>
  7. Date: 7 Sep 90 07:47:15 GMT
  8. Sender: news@ai.mit.edu
  9. Organization: nil
  10. Lines: 195
  11.  
  12.  
  13.    Here's a program which I've found very useful. It creates a list of
  14. files available from a Kermit server and interactively let's you KGET
  15. individual entries. It does a "D" "G" PKT (mentioned in the HP48
  16. manual) and so needs certain customization to fit into your host's
  17. particular `ls -l' format.
  18.  
  19. So, after KGETing the directory, edit KFILES:
  20.  
  21. KFILES
  22. \<< "D" "G" PKT
  23.   10 CHR SPLIT OBJ\-> 3 -
  24.   \-> N
  25.   \<< DROP 1 N
  26.     START DUP
  27.       SIZE 55 SWAP SUB
  28.       IFERR "'"
  29.         SWAP + OBJ\->
  30.       THEN
  31.       END 
  32.       N ROLLD
  33.     NEXT 
  34.     N \->LIST
  35.   \>>
  36.   3 ROLLD
  37.   DROP2 'KDAT' STO
  38. \>>
  39.  
  40.   The routine initially breaks up the received string on LF (SPLIT
  41. returns a list of substrings). The first two lines will be "ls -l" and
  42. "total ###", the last line will be an empty line (the listing will end
  43. with an LF) - "3 -" following OBJ-> reduces the actual number of lines
  44. by 3. The DROP before the START loop removes the empty line from the
  45. stack. Then each round in the loop one file name substring is
  46. extracted from its line and the list of lines rolled down. The IFERR
  47. construct is to avoid errors related to invalid characters (like
  48. dashes) in file names - such names cannot be used with KGET anyway, so
  49. they're kept as strings instead of names. The constant 55 is the
  50. column in an `ls -l' listing where the actual filename appears.
  51. Finally, the names are bundled up into a list, the initial two lines
  52. removed, and the list stored in KDAT.
  53.  
  54.  
  55.    To use KMENU, place your computer's Kermit in server mode, and
  56. press VAR 'KDAT' PURGE CST KMENU. KMENU will ask Kermit for a list
  57. of files and display a name catalog.
  58.  
  59. KMENU will ignore all keys except the follwing:
  60.  
  61.     [up arrow]        One name up
  62.     [down arrow]        One name down
  63.     [ENTER]            Put the current name on the stack
  64.     [backspace]        Exit
  65.     [ATTN]            Fire escape (will leave -1 on the stack)
  66.  
  67. And in the menu:
  68.  
  69.     KGET            KGET the current name
  70.     KFILES            Update catalog
  71.  
  72.  
  73.  
  74.    It's not the fastest program around. Also note that KMENU stores
  75. the list of names in KDAT; as long as such a variable exists and
  76. contains a list object, KMENU will not automatically do KFILES upon
  77. entry. Worth mentioning is also that KMENU will KGET objects into the
  78. current directory.
  79.  
  80. Good luck!
  81.  
  82.  
  83.  
  84. [KMENU,KFILES,KDISP,KTOP,SPLIT: #F055h 1430 bytes]
  85.  
  86. %%HP: T(3)A(R)F(.);
  87. DIR
  88.   CST { KMENU }
  89.   KTOP
  90.     \<< KDAT SIZE
  91. " files:" + 1 DISP
  92.     \>>
  93.   KDISP
  94.     \<< \-> P MX C
  95.       \<<
  96.         IF P MX 6 -
  97. >
  98.         THEN MX 5 -
  99.         ELSE P C -
  100.         END 1 MAX \->
  101. W
  102.         \<< W 2 MX W
  103. - 1 + 6 MIN 1 +
  104.           FOR L DUP
  105. " " KDAT 3 ROLL GET
  106. + L DISP 1 +
  107.           NEXT DROP
  108. W
  109.         \>>
  110.       \>>
  111.     \>>
  112.   KMENU
  113.     \<< CLLCD KDAT
  114. TYPE 5 \=/
  115.       \<< KFILES
  116.       \>> IFT KDAT
  117. SIZE 1 \-> MX P
  118.       \<< { KGET
  119. KFILES } TMENU KTOP
  120. P MX 4 KDISP 134
  121. CHR \-> W ARROW
  122.         \<<
  123.           DO ARROW
  124. KDAT P GET + P W -
  125. 2 + DISP -1 WAIT
  126. " " KDAT P GET + P
  127. W - 2 + DISP 7 FS?C
  128.             \<< KTOP
  129.             \>> IFT \->
  130. K
  131.             \<<
  132.               CASE
  133. K 25.1 SAME P 1 >
  134. AND
  135. THEN 'P' DECR W <
  136.   \<< P MX 4 KDISP
  137. 'W' STO
  138.   \>> IFT 0
  139. END K 35.1 SAME P
  140. MX < AND
  141. THEN 'P' INCR W 5 +
  142. >
  143.   \<< P MX 1 KDISP
  144. 'W' STO
  145.   \>> IFT 0
  146. END K 51.1 SAME
  147. THEN KDAT P GET 0
  148. END K 11.1 SAME
  149. THEN
  150.   IFERR KDAT P GET
  151. KGET P MX 4 KDISP
  152. 'W' STO KTOP
  153.   THEN ERRM 1 DISP
  154. 7 SF
  155.   END 0
  156. END K 12.1 SAME
  157. THEN
  158.   IFERR KFILES
  159.   THEN ERRM 1 DISP
  160. 7 SF
  161.   END 0
  162. END K 55.1 SAME
  163. THEN 1
  164. END 0
  165.               END
  166.             \>>
  167.           UNTIL
  168.           END 0
  169. MENU
  170.         \>>
  171.       \>>
  172.     \>>
  173.   KFILES
  174.     \<< "D" "G" PKT
  175. 10 CHR SPLIT OBJ\-> 3
  176. - \-> N
  177.       \<< DROP 1 N
  178.         START DUP
  179. SIZE 55 SWAP SUB
  180.           IFERR "'"
  181. SWAP + OBJ\->
  182.           THEN
  183.           END N
  184. ROLLD
  185.         NEXT N
  186. \->LIST
  187.       \>> 3 ROLLD
  188. DROP2 'KDAT' STO
  189.     \>>
  190.   SPLIT
  191.     \<< 1 \-> T N
  192.       \<<
  193.         WHILE DUP T
  194. POS DUP
  195.         REPEAT SWAP
  196. 1 3 ROLL \-> S B E
  197.           \<< S B E 1
  198. - SUB S E 1 + S
  199. SIZE SUB
  200.           \>> 'N'
  201. INCR DROP
  202.         END DROP N
  203. \->LIST
  204.       \>>
  205.     \>>
  206. END
  207.  
  208.  
  209.